<?php 
include_once('connection/connection.php');
//session_start();
//ob_start();
include('header.php');
include('menu.php');
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<title>Questionnaire No.3</title>
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
</head>
<body>
<?php
$loc_id = $_SESSION['loc_id'];
if(isset($_POST['submit']))
{
		$fclick = true;
		//echo $loc_id;
		$q1="SELECT DISTINCT  habit_name, habit_code FROM tbl_dtls_q3_habit WHERE status_e_nt='Existing' AND loc_id='$loc_id' order by habit_code asc";
		//echo $q1;
		$result1=mysql_query($q1);
		$rows_num = mysql_num_rows($result1);
		$_SESSION['rows_num']=$rows_num;
		for($i=1; $i<=$rows_num; $i++)
		{
			$hcode='wa_habit_code'.$i;
			$hname='wa_habit_name'.$i;
			$type_habit='type_habit'.$i;
			$avg_water_recieve='water_received_household'.$i;
			$avg_water_spent='monthly_spent_household'.$i;
			$house_conn='house_connection_qty'.$i;
			$handpump_qty='handpump_qty'.$i;
			$handpump_distance='handpump_avg_dist'.$i;
			$comm_tap_qty='common_tap_qty'.$i;
			$comm_tap_distance='common_tap_avg_dist'.$i;
			$trad_src_qty='tradi_source_qty'.$i;
			$trad_src_distance='tradi_source_avg_dist'.$i;
			$tanker_qty='tankers_qty'.$i;
			$tanker_distance='tankers_avg_dist'.$i;
			$water_nt_avail='water_not_available'.$i;
			$pre_monsoon='num_hrs_pre_monsoon'.$i;
			$post_monsoon='num_hrs_post_monsoon'.$i;
			
			$hcode=$_POST[$hcode];
			$hname=$_POST[$hname];
			$type_habit=$_POST[$type_habit];
			$avg_water_recieve=$_POST[$avg_water_recieve];
			$avg_water_spent=$_POST[$avg_water_spent];
			$house_conn=$_POST[$house_conn];
			$handpump_qty=$_POST[$handpump_qty];
			$handpump_distance=$_POST[$handpump_distance];
			$comm_tap_qty=$_POST[$comm_tap_qty];
			$comm_tap_distance=$_POST[$comm_tap_distance];
			$trad_src_qty=$_POST[$trad_src_qty];
			$trad_src_distance=$_POST[$trad_src_distance];
			$tanker_qty=$_POST[$tanker_qty];
			$tanker_distance=$_POST[$tanker_distance];
			$water_nt_avail=$_POST[$water_nt_avail];
			$pre_monsoon=$_POST[$pre_monsoon];
			$post_monsoon=$_POST[$post_monsoon];
			/*------------------------------------------*/
			$arr_habit_name[$i]["name"]=$hname;
			$arr_habit_code[$i]["code"]=$hcode;
			$_SESSION['arr_habit_name']=$arr_habit_name;
			$_SESSION['arr_habit_code']=$arr_habit_code;
			/*-------------------------------------------*/
			$q2="INSERT INTO tbl_dtls_q3_water_status(loc_id, habitation_code, habitation_name, type_habit, avg_water_recieve, avg_water_spent, house_connection, hand_pump_qty, hand_pump_distance, common_tap_qty, common_tap_distance, traditional_src_qty,   traditional_src_distance, tanker_qty, tanker_distance, water_not_available, pre_monsoon, post_monsoon) VALUES ('$loc_id', '$hcode', '$hname', '$type_habit', '$avg_water_recieve', '$avg_water_spent', '$house_conn', '$handpump_qty', '$handpump_distance', '$comm_tap_qty', '$comm_tap_distance', '$trad_src_qty', '$trad_src_distance', '$tanker_qty', '$tanker_distance', '$water_nt_avail', '$pre_monsoon', '$post_monsoon')";
			$result2=mysql_query($q2);
			}	
			if($result2)
			{
				header('Location: questionnaire3_3.php');
				//echo "Success";
			}
			else
			{
				echo "Unsuccessful Insertion";
			}	
}
else
{
	$fclick = false;
	$flag=0;
}
?>
<div align="center">
<form action="" method="post" enctype="multipart/form-data" name="questionnaire3_2" id="questionnaire3_2" onSubmit="return validate2()">
	<table border="0" width="1000" id="table1" cellspacing="0" cellpadding="0">
		<tr>
			<td height="30">
			<p align="center">
			<font face="Verdana" style="font-size: 10pt; font-weight: 700" color="#000000">
			Questionnaire No. 3</font></p></td>
		</tr>
		<tr>
			<td height="19">
			<p align="center">
			<font face="Arial" style="font-size: 8.5pt" color="#000000">For 
			Field Survey (Village Level questionnaire) </font></p></td>
		</tr>
		<tr>
			<td height="18">
			<p align="center">
			<font style="font-size: 8.5pt" face="Arial" color="#000000">Page 2</font></p></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="22"><font color="#000000">&nbsp;
			<span style="font-weight: 700">
			<font face="Arial" style="font-size: 8.5pt">3. STATUS OF WATER 
			AVAILABILITY (Average Household Level Survey)</font></span></font></td>
		</tr>
		<tr>
			<td>
			<table border="0" width="1050" id="table4" cellspacing="1" cellpadding="0" bgcolor="#FDF9EE">
				<tr>
					<td colspan="16"><span style="font-size: 4pt">&nbsp;</span></td>
				</tr>
				<tr>
					<td width="145" align="center" rowspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style:normal" face="Verdana" color="#990000">
				  Habitation</font></address>					</td>
					<td align="center" width="45" rowspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
				  Type MH/ OH</font></address>					</td>
					<td align="center" width="78" rowspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
						Average Water received per household (lpd)</font>
			      </address>					</td>
					<td align="center" width="87" rowspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<font face="Verdana" style="font-size: 8.5pt; font-style: normal" color="#990000">
				  Average Monthly Spent on water per household (Rs/month)</font></address>					</td>
					<td align="center" width="65" valign="top" height="31" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">House connection</font>
				  </address>					</td>
					<td align="center" height="31" colspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">Hand Pump</font>
					</address>					</td>
					<td align="center" height="31" colspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
						<font face="Verdana" color="#990000">Common Tap</font></span>
					</address>
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
				  <font face="Verdana" color="#990000">P&amp;T, PSP</font></span></address>					</td>
					<td align="center" height="31" colspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
				  <font face="Verdana" color="#990000">Traditional Sources</font></span>
					</address>					</td>
					<td align="center" height="31" colspan="2" valign="top" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">Tankers</font></td>
					<td align="center" width="56" valign="top" rowspan="2" bgcolor="#F7E6B7">
					<address>&nbsp;</address>
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
						<font face="Verdana" color="#990000">Water Not Available in Months(No.)</font></span>
					</address>					</td>
					<td align="center" height="31" colspan="2" valign="top" bgcolor="#F7E6B7">
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
						<font face="Verdana" color="#990000">No. of Hrs./ day 
						available </font></span>
				    </address>					</td>
				</tr>
				<tr>
					<td align="center" width="65" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
						Qty (lpd)</font>
				  </address>					</td>
					<td align="center" width="67" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
						Qty (lpd)</font>
				  </address>				  </td>
					<td align="center" width="63" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
						Average Distance Traveled (m) </font>
				  </address>					</td>
					<td align="center" width="56" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
						Qty (lpd)</font>
				  </address>					</td>
					<td align="center" width="61" valign="top" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
					Average Distance Traveled (m)</font></td>
					<td align="center" width="53" valign="top" bgcolor="#F7E6B7">
					<address>
						<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
						Qty (lpd)</font>
				  </address>					</td>
					<td align="center" width="53" valign="top" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
					Average Distance Traveled (m)</font></td>
					<td align="center" width="51" valign="top" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
					Qty (lpd)</font></td>
					<td align="center" width="53" valign="top" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">
					Average Distance Traveled (m)</font></td>
					<td align="center" width="50" valign="top" bgcolor="#F7E6B7">
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
						<font face="Verdana" color="#990000">Pre Monsoon</font></span>
					</address>	
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
						<font face="Verdana" color="#990000">(hr/day)</font></span>
					</address>
					</td>
					<td align="center" width="50" valign="top" bgcolor="#F7E6B7">
					<font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#990000">Post Monsoon</font>
					<address>
						<span style="font-style: normal; font-size: 8.5pt">
						<font face="Verdana" color="#990000">(hr/day)</font></span>
					</address></td>
				</tr>
				<?php
				$q5="SELECT DISTINCT  habit_name, habit_code FROM tbl_dtls_q3_habit WHERE status_e_nt='Existing' AND loc_id='$loc_id'";
				//echo $q5;
				$result5=mysql_query($q5);
				$i=1;
			    while(list($name, $id)=mysql_fetch_array($result5))
				{
					//echo $key;echo $val;exit;
					?>
					<tr align="center">
					<td width="145" align="center">
						<input type="text" name="wa_habit_name<?php echo $i;?>" id="wa_habit_name<?php echo $i;?>" value="<?php echo $name;?>" size="20" class="txt4" readonly />
					  <input type="hidden" name="wa_habit_code<?php echo $i;?>" id="wa_habit_code<?php echo $i;?>" value= "<?php echo $id;?>" size="20" class="txt4" />					</td>
					<td align="center" width="45"><input type="text" name="type_habit<?php echo $i;?>" id="type_habit<?php echo $i;?>" value="<?php if($i==1){ echo "MH"; } else { echo "OH"; } ?>" size="2" class="txt_1" readonly/></td>
					<td width="78" align="center">
						<p align="center">
					  <input type="text" name="water_received_household<?php echo $i;?>" id="water_received_household<?php echo $i;?>" value= "0" size="20" class="txt5" readonly onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="87" align="center"><input type="text" name="monthly_spent_household<?php echo $i;?>" id="monthly_spent_household<?php echo $i;?>" size="20" class="txt5" value= "0" onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="65" align="center"><input type="text" name="house_connection_qty<?php echo $i;?>" id="house_connection_qty<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" onChange="add2(<?php echo $i;?>)"/></td>
					<td width="67" align="center">
					  <input type="text" name="handpump_qty<?php echo $i;?>" id="handpump_qty<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" onChange="add2(<?php echo $i;?>)"/></td>
					<td width="63" align="center">
					  <input type="text" name="handpump_avg_dist<?php echo $i;?>" id="handpump_avg_dist<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="56" align="center">
					  <input type="text" name="common_tap_qty<?php echo $i;?>" id="common_tap_qty<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" onChange="add2(<?php echo $i;?>)"/></td>
					<td width="61" align="center">
					  <input type="text" name="common_tap_avg_dist<?php echo $i;?>" id="common_tap_avg_dist<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="53" align="center">
					  <input type="text" name="tradi_source_qty<?php echo $i;?>" id="tradi_source_qty<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" onChange="add2(<?php echo $i;?>)"/></td>
					<td width="53" align="center">
					  <input type="text" name="tradi_source_avg_dist<?php echo $i;?>" id="tradi_source_avg_dist<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="51" align="center">
					  <input type="text" name="tankers_qty<?php echo $i;?>" id="tankers_qty<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" onChange="add2(<?php echo $i;?>)"/></td>
					<td width="53" align="center">
					  <input type="text" name="tankers_avg_dist<?php echo $i;?>" id="tankers_avg_dist<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="56" align="center">
					  <input type="text" name="water_not_available<?php echo $i;?>" id="water_not_available<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)"/></td>
					<td width="50" align="center">
						<input type="text" name="num_hrs_pre_monsoon<?php echo $i;?>" id="num_hrs_pre_monsoon<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" /></td>
					<td width="50" align="center">
						<input type="text" name="num_hrs_post_monsoon<?php echo $i;?>" id="num_hrs_post_monsoon<?php echo $i;?>" value= "0" size="20" class="txt6" onFocus="blank(this)" onBlur="unblank(this);float(this)" /></td>
				</tr>
				<?php  $i++;
				} ?>
				<input type="hidden" name="housecount" id="housecount" value="<?php echo $i; ?>">
				</table>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="22">&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td><font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#FF0000">&nbsp;&nbsp;</font>			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td><font style="font-size: 8.5pt; font-style: normal" face="Verdana" color="#FF0000">
				&nbsp;&nbsp;</font>			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>
			<p align="center">
			<input type="submit" value="Click for Continue" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px"></p></td>
		</tr>
		<!--<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>
			<p align="center">
			<font style="font-size: 8.5pt" face="Verdana" color="#990000">
			<a href="questionnaire3_2.htm"><font color="#990000">
			<span style="text-decoration: none"></span></font><font color="#990000">
			<span style="text-decoration: none"><a href="questionnaire3_3.htm"><span style="text-decoration: none">
			<font color="#990000">Next Page
			<img border="0" src="images/right_pointer_web_designing.GIF" width="13" height="13"><img border="0" src="images/right_pointer_web_designing.GIF" width="13" height="13"></font></span></a></span></font></a></font></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>-->
	</table>
	</form>
</div>

</body>
</html>
